// ========================================================================= //

// includes
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
#include "limits.h"
#include "float.h"



#define JOTAI_NUM_RANDS_ 25

const unsigned rand_primes[JOTAI_NUM_RANDS_] = {179, 103, 479, 647, 229, 37, 271, 557, 263, 607, 18743, 50359, 21929, 48757, 98179, 12907, 52937, 64579, 49957, 52567, 507163, 149939, 412157, 680861, 757751};

int next_i() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_];
}

float next_f() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_] / 757751.0F;
} 


// Usage menu
void usage() {
    printf("%s", "Usage:\n\
    prog [ARGS]\n\
\nARGS:\n\
       0            int-bounds\n\
       1            big-arr\n\
       2            big-arr-10x\n\
       3            empty\n\
\n\
");

}


// ------------------------------------------------------------------------- //

#define NULL ((void*)0)
typedef unsigned long size_t;  // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__;  // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef  int /*<<< orphan*/  u8 ;

/* Variables and functions */
 int /*<<< orphan*/  BB_TYPE_11A ; 
#define  RATE_12M 135 
#define  RATE_18M 134 
#define  RATE_24M 133 
#define  RATE_36M 132 
#define  RATE_48M 131 
#define  RATE_54M 130 
#define  RATE_6M 129 
#define  RATE_9M 128 

__attribute__((used)) static
void
s_vCalculateOFDMRParameter(
	unsigned char byRate,
	u8 bb_type,
	unsigned char *pbyTxRate,
	unsigned char *pbyRsvTime
)
{
	switch (byRate) {
	case RATE_6M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9B;
			*pbyRsvTime = 44;
		} else {
			*pbyTxRate = 0x8B;
			*pbyRsvTime = 50;
		}
		break;

	case RATE_9M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9F;
			*pbyRsvTime = 36;
		} else {
			*pbyTxRate = 0x8F;
			*pbyRsvTime = 42;
		}
		break;

	case RATE_12M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9A;
			*pbyRsvTime = 32;
		} else {
			*pbyTxRate = 0x8A;
			*pbyRsvTime = 38;
		}
		break;

	case RATE_18M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9E;
			*pbyRsvTime = 28;
		} else {
			*pbyTxRate = 0x8E;
			*pbyRsvTime = 34;
		}
		break;

	case RATE_36M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9D;
			*pbyRsvTime = 24;
		} else {
			*pbyTxRate = 0x8D;
			*pbyRsvTime = 30;
		}
		break;

	case RATE_48M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x98;
			*pbyRsvTime = 24;
		} else {
			*pbyTxRate = 0x88;
			*pbyRsvTime = 30;
		}
		break;

	case RATE_54M:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x9C;
			*pbyRsvTime = 24;
		} else {
			*pbyTxRate = 0x8C;
			*pbyRsvTime = 30;
		}
		break;

	case RATE_24M:
	default:
		if (bb_type == BB_TYPE_11A) { /* 5GHZ */
			*pbyTxRate = 0x99;
			*pbyRsvTime = 28;
		} else {
			*pbyTxRate = 0x89;
			*pbyRsvTime = 34;
		}
		break;
	}
}

// ------------------------------------------------------------------------- //

int main(int argc, char *argv[]) {

    if (argc != 2) {
        usage();
        return 1;
    }

    int opt = atoi(argv[1]);
    switch(opt) {

    // int-bounds
    case 0:
    {
          unsigned char byRate = 100;
        
          int bb_type = 100;
        
          int _len_pbyTxRate0 = 1;
          unsigned char * pbyTxRate = (unsigned char *) malloc(_len_pbyTxRate0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyTxRate0; _i0++) {
            pbyTxRate[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          int _len_pbyRsvTime0 = 1;
          unsigned char * pbyRsvTime = (unsigned char *) malloc(_len_pbyRsvTime0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyRsvTime0; _i0++) {
            pbyRsvTime[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          s_vCalculateOFDMRParameter(byRate,bb_type,pbyTxRate,pbyRsvTime);
          free(pbyTxRate);
          free(pbyRsvTime);
        
        break;
    }
    // big-arr
    case 1:
    {
          unsigned char byRate = 255;
        
          int bb_type = 255;
        
          int _len_pbyTxRate0 = 65025;
          unsigned char * pbyTxRate = (unsigned char *) malloc(_len_pbyTxRate0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyTxRate0; _i0++) {
            pbyTxRate[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          int _len_pbyRsvTime0 = 65025;
          unsigned char * pbyRsvTime = (unsigned char *) malloc(_len_pbyRsvTime0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyRsvTime0; _i0++) {
            pbyRsvTime[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          s_vCalculateOFDMRParameter(byRate,bb_type,pbyTxRate,pbyRsvTime);
          free(pbyTxRate);
          free(pbyRsvTime);
        
        break;
    }
    // big-arr-10x
    case 2:
    {
          unsigned char byRate = 10;
        
          int bb_type = 10;
        
          int _len_pbyTxRate0 = 100;
          unsigned char * pbyTxRate = (unsigned char *) malloc(_len_pbyTxRate0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyTxRate0; _i0++) {
            pbyTxRate[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          int _len_pbyRsvTime0 = 100;
          unsigned char * pbyRsvTime = (unsigned char *) malloc(_len_pbyRsvTime0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyRsvTime0; _i0++) {
            pbyRsvTime[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          s_vCalculateOFDMRParameter(byRate,bb_type,pbyTxRate,pbyRsvTime);
          free(pbyTxRate);
          free(pbyRsvTime);
        
        break;
    }
    // empty
    case 3:
    {
          unsigned char byRate = ((-2 * (next_i()%2)) + 1) * next_i();
        
          int bb_type = ((-2 * (next_i()%2)) + 1) * next_i();
        
          int _len_pbyTxRate0 = 1;
          unsigned char * pbyTxRate = (unsigned char *) malloc(_len_pbyTxRate0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyTxRate0; _i0++) {
            pbyTxRate[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          int _len_pbyRsvTime0 = 1;
          unsigned char * pbyRsvTime = (unsigned char *) malloc(_len_pbyRsvTime0*sizeof(unsigned char));
          for(int _i0 = 0; _i0 < _len_pbyRsvTime0; _i0++) {
            pbyRsvTime[_i0] = ((-2 * (next_i()%2)) + 1) * next_i();
          }
        
          s_vCalculateOFDMRParameter(byRate,bb_type,pbyTxRate,pbyRsvTime);
          free(pbyTxRate);
          free(pbyRsvTime);
        
        break;
    }
    default:
        usage();
        break;

    }

    return 0;
}
